package cn.com.open.itembank.logic.questiontype;

import cn.com.open.itembank.common.enums.ItemType;
import cn.com.open.itembank.dto.QuestionImportModel;

/**
 * Created by lucky on 2017/12/19.
 */
public class QuestionTypeFactory {

    private QuestionImportModel importModel;

    /**
     * Instantiates a new Question type factory.
     *
     * @param model the model
     */
    public QuestionTypeFactory(QuestionImportModel model) {
        importModel = model;
    }

    /**
     * Get instance question type base.
     *
     * @param innerType the inner type
     * @return the question type base
     */
    public QuestionTypeBase getInstance(int innerType) {
        QuestionTypeBase questionTypeBase = null;

        switch (ItemType.fromValue(innerType)) {
            case SINGLECHOICE:
                questionTypeBase = new SingleChoiceItem(importModel);
                break;
            case MULTIPLECHOICE:
                questionTypeBase = new MultipleChoiceItem(importModel);
                break;
            case JUDGEMENT:
                questionTypeBase = new JudgementItem(importModel);
                break;
            case TEXTENTRY:
                questionTypeBase = new TextEntryItem(importModel);
                break;
            case READINGCOMPREHENSION:
                questionTypeBase = new ReadingComprehensionItem(importModel);
                break;
            case CLOZE:
                questionTypeBase = new ClozeItem(importModel);
                break;
            case EXTENDEDTEXT:
                questionTypeBase = new ExtendedTextItem(importModel);
                break;
            case MATCH:
                questionTypeBase = new MatchItem(importModel);
                break;
            case COMPOSITE:
                questionTypeBase = new CompositeItem(importModel);
                break;
            case UPLOAD:
                questionTypeBase = new UploadItem(importModel);
                break;
            case ORDER:
                questionTypeBase = new OrderItem(importModel);
                break;
            default:
                break;
        }

        return questionTypeBase;
    }
}
